﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using DevTrends.MvcDonutCaching;
using KMF.Common;
using KMF.DAL;
using KMF.Utility;
using KMF.WebUI.CustomHelpers;
using KMF.WebUI.Infrastructure;
using System.Security.Cryptography;

namespace KMF.WebUI.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        [DonutOutputCache(CacheProfile = "OneDay")]
        public ActionResult Index()
        {
            //var keyw = Utility.Common.returnConfig("KeyWeb");
            //var url = Request.Url;
            //if (url != null && !url.Host.Contains("localhost"))
            //{
            //    if (Session[SessionConfig.WebsiteSecurity] == null)
            //    {
            //        var md5 = new MD5CryptoServiceProvider();
            //        var utf8 = new UTF8Encoding();
            //        var dmn = url.Host;
            //        var keyCurrent =
            //            BitConverter.ToString(
            //                md5.ComputeHash(utf8.GetBytes(dmn + "07-2E-49-5F-DC-76-E5-9F-C5-BB-41-55-C3-46-DE-A8")));
            //        // chek domain 
            //        if (!keyw.Equals(keyCurrent))
            //        {
            //            return RedirectToAction("IndexSecurity");                
            //        }
            //    }
                
            //    ViewBag.Canonical = url.AbsoluteUri;
            //}

            var model = FunctionHelpers.GetWebInfo();
            return View(model);
        }

        public ActionResult IndexSecurity()
        {
            return PartialView();
        }
    }
}
